package com.villaday.idf.util;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * 自定义移动计算距离方法
 * Created by Administrator on 2017/3/28.
 */

public class ScrollViewUtil extends ScrollView {

    public OnScrollViewChangedListener onScrollViewChangedListener;

    public ScrollViewUtil(Context context) {
        super(context);
    }

    public ScrollViewUtil(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ScrollViewUtil(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    //设置移动的监听事件
    public void setOnScollChangedListener(OnScrollViewChangedListener onScrollViewChangedListener) {
        this.onScrollViewChangedListener = onScrollViewChangedListener;
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
        if (onScrollViewChangedListener != null) {
            onScrollViewChangedListener.onScrollChanged(this, x, y, oldx, oldy);
        }
    }

    public interface OnScrollViewChangedListener {
        void onScrollChanged(ScrollViewUtil scrollViewUtil, int x, int y, int oldx, int oldy);
    }

}
